from base.base_models import BaseModel
from tortoise import fields


class GalleryCategory(BaseModel):
    name = fields.CharField(max_length=10, description="相册分类名称")

    class Meta:
        table = "tb_gallery_category"


class Gallery(BaseModel):
    title = fields.CharField(max_length=50, description="相册标题")
    content = fields.CharField(max_length=255, description="相册内容", null=True)
    image = fields.CharField(max_length=255, description="相册封面")
    image_hash = fields.CharField(max_length=32, description="相册封面hash")
    category = fields.ForeignKeyField(
        "models.GalleryCategory", related_name="galleries", description="相册分类"
    )

    class Meta:
        table = "tb_gallery"
